import { OnInit, Component, ViewChild } from '@angular/core';
import { StartCourseListComponent } from './start-course-list.component';
import { StringToNumberPipe } from '@shared/pipe/string-to-number.pipe';

@Component({
  selector: 'app-start-course-view',
  templateUrl: './start-course-view.component.html',
  styles: [],
  providers: [StringToNumberPipe],
})
export class StartCourseViewComponent implements OnInit {
  constructor() {}

  @ViewChild('startCourseListComponent', { static: false })
  startCourseListComponent: StartCourseListComponent;

  /**
   * 条件查询参数
   */
  queryParams = {
    year: '',
    termType: null,
    courseName: null,
    teacherName: null,
    isOpen: null,
  };

  /**
   * 下半学年
   */
  nextYear: string = null;

  getNextYear() {
    this.nextYear = this.queryParams.year;
    // this.nextYear = new Date().toISOString() + 1;
  }

  /**
   * 添加课程开课信息
   */
  create() {
    this.startCourseListComponent.create();
  }

  /**
   * 刷新
   */
  reflesh() {
    this.startCourseListComponent.loadData();
  }

  /**
   * 查询
   */
  onSearch() {
    this.startCourseListComponent.loadData();
  }

  /**
   * 重置表单
   */
  onResetForm() {
    this.queryParams.year = '';
    this.queryParams.termType = null;
    this.queryParams.courseName = null;
    this.queryParams.teacherName = null;
    this.queryParams.isOpen = null;
  }

  ngOnInit() {}
}
